import { saasTosj, fillInputDone } from '../../common.js';
import { hsqjInputJson, gdzczjJson } from '../data/hsqjData.js';
export function fillHsqj(saasData) {
  try {
    console.log(saasData);
    let data = saasTosj(saasData, hsqjInputJson, gdzczjJson);
    let currentBtn = $('#editList .active').attr('data-bbid');
    let contents = $(
      `#reportBody > iframe[id=iframe_${currentBtn}]`
    ).contents();
    // 数据填写
    Object.keys(data).forEach((item) => {
      let input = contents.find(`#${item}`);
      const canWrite = $(input).prop('disabled');
      // 只填写税局让填写的
      if (canWrite === false) {
        input.focus();
        // input.val(parseFloat('1220').toFixed(2));
        input.val(parseFloat(data[item]).toFixed(2));
        input.blur();
      }
    });
    fillInputDone({
      tax: 'hsqj',
      success: true,
      message: '汇算清缴-填报成功',
    });
  } catch (e) {
    console.log(e);
    fillInputDone({
      tax: 'hsqj',
      success: false,
      message: '汇算清缴-填报失败，请联系技术人员',
    });
  }
}
